package com.qf.edu.business.student.controller;

import com.qf.edu.business.student.service.StuService;
import com.qf.edu.commons.web.base.BaseController;
import com.qf.edu.data.base.R;
import com.qf.edu.data.entity.Student;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stu")
@Slf4j
@Tag(name = "学生管理模块", description = "管理学生的相关接口")
public class StuController extends BaseController<StuService> {

    @Operation(summary = "新增学生的接口", description = "用于新增学生")
    @Parameters({
            @Parameter(name = "name", description = "学生的姓名", required = true, schema = @Schema(type = "String"), in = ParameterIn.DEFAULT),
            @Parameter(name = "age", description = "学生的年龄", required = true, schema = @Schema(type = "int"), in = ParameterIn.DEFAULT),
    })
    @PostMapping("/insert")
    public R insert(@Validated Student student){
        log.debug("新增学生的信息.....{}", student);
        return R.succ(getBaseService().save(student));
    }
}
